//
//  UIView+OCAddtion.m
//  ocVB
//
//  Created by apple on 2016/10/27.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "UIView+OCAddtion.h"

@implementation UIView (OCAddtion)

+ (instancetype)makeButtonWithImgName:(NSString *)imgName backgroundImagName:(NSString *)backImgName title:(NSString *)title titleColor:(UIColor *)color tagert:(id)obj selector:(SEL)selector{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:title forState:UIControlStateNormal];
    if (color == nil?UIColor.blackColor:color) {
        [btn setTitleColor:color forState:UIControlStateNormal];
    }
    if (imgName != nil) {
        [btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
    }
    if (backImgName != nil) {
        [btn setBackgroundImage:[UIImage imageNamed:backImgName] forState:UIControlStateNormal];
    }
    [btn addTarget:obj action:selector forControlEvents:UIControlEventTouchUpInside];
    [btn sizeToFit];
    
    return btn;
    
    
}

+ (instancetype)makeButtonWithImgName:(NSString *)imgName title:(NSString *)title titleFont:(CGFloat)size titleColor:(UIColor *)color tagert:(id)obj selector:(SEL)selector{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:title forState:UIControlStateNormal];
    if (color == nil?UIColor.blackColor:color) {
        [btn setTitleColor:color forState:UIControlStateNormal];
    }
    if (imgName != nil) {
        [btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
    }
    [btn addTarget:obj action:selector forControlEvents:UIControlEventTouchUpInside];
    
    btn.titleLabel.font = [UIFont systemFontOfSize:size];
    [btn sizeToFit];
    return btn;
    
}

//+ (instancetype)makeButtonItemWith:(NSString *)title titleColor:(UIColor *)color imgName:(NSString *)imgName target:(id)obj selector:(SEL)selector{
//    UIBarButtonItem *item = [[UIBarButtonItem alloc] init];
//    UIButton *btn = [UIButton makeButtonWithImgName:imgName backgroundImagName:nil title:title titleColor:color tagert:obj selector:selector];
//    item.customView = btn;
//    return item;
//    
//    
//    
//}



@end
